<?php

use Illuminate\Database\Seeder;
use App\Models\LoginLog;
use App\Models\User;
class LoginLogTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $user_ids = User::all()->pluck('id')->toArray();

        $faker = app(Faker\Generator::class);
        $logs = factory(LoginLog::class)
                    ->times(300)
                    ->make()->each(function($log, $index) use ($faker, $user_ids) {
                        $log->user_id = $faker->randomElement($user_ids);
                    });
        LoginLog::insert($logs->toArray());
    }
}
